//
//  NightLabel.m
//  UI外传_夜间模式
//
//  Created by dllo on 15/12/10.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "NightLabel.h"

@implementation NightLabel

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"day" object:nil];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews
{

    if (YES == [[NSUserDefaults standardUserDefaults] boolForKey:@"isNight"]) {
        self.textColor = [UIColor orangeColor];
    } else {
        self.textColor = [UIColor blueColor];
    }


    // 夜间模式消息通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nightAction) name:@"night" object:nil];
    
    // 日间模式消息通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dayAction) name:@"day" object:nil];
    
}

- (void)dayAction
{
    self.textColor = [UIColor blueColor];
}

- (void)nightAction
{
    self.textColor = [UIColor orangeColor];
}


@end
